package com.axonactive.training.maganedbean;

import java.util.Currency;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;

import com.axonactive.training.model.Balance;
import com.axonactive.training.service.BalanceService;

@ManagedBean
@RequestScoped
public class BalanceBean {
	private float balance;
	
	@Inject
	BalanceService balanceService;
	
	public Balance getCurrentBalance(){
		return balanceService.getBalance();
	}
	
	public void saveBalance(){
		Balance newBalance = new Balance(balance, Currency.getInstance("VND"));
		balanceService.saveBalance(newBalance);
	}

	public float getBalance() {
		return balance;
	}

	public void setBalance(float balance) {
		this.balance = balance;
	}
}
